//
//  LGSExecutor.h
//  LogicSim
//
//  Created by Jeremy Pereira on 05/04/2012.
//  Copyright (c) 2012 __MyCompanyName__. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "LGSNode.h"

/*!
 *  @file LGSExecutor.h
 *  @brief A class that executes by evaluating nodes.  
 *
 *  It maintains a list of nodes that nedd evaluation by time in the future to
 *  evaluate.
 */

/*!
 *  @brief an object that evaluates the nodes of a logic circuit continuously.
 */
@interface LGSExecutor : NSObject

/*!
 *  @brief evaluate the circuit starting with the nodes supplied.
 *  @param initialSet initial set of nodes to evaluate
 *  @param maxIterations  number of nodes to evaluate before stopping, or 0 if
 *                        you want it to go on foreever.
 *  @return number of iterations actually run before everything stabilised.
 */
-(unsigned long) evaluateWithInitialSet: (NSMutableOrderedSet*) initialSet
						  maxIterations: (unsigned long) maxIterations;

/*!
 *  @brief trace flag, if true, each evaluation is recorded
 */
@property (nonatomic, assign) bool trace;
/*!
 *  @brief if true causes evaluation to stop
 */
@property (assign) bool shouldStop;

/*!
 *  @brief Gives a count of nodes that will be evaluated at the given tick
 *  @param tickNumber offset in ticks from now of gates that will be evaluated
 *  @return the number of nodes to be evaluated at the given time.
 */
-(size_t) nodeCountAtTick: (TimeTick) tickNumber;

/*!
 *  @brief Remove all the nodes that we would otherwise be evaluating.
 */
-(void) removeAllNodes;

@end
